{{useCss "/app-pages/css/admin/createbutton.scss"}}
<div class="createbutton">
    {{#each $Cache.admin.createbutton.list.button}}
    <table>
        <thead>
            <td colspan="4">一级菜单
				<a class="method" event-click="{{'$Top.$Event.admin.createbutton.removeButton'}}">删除此菜单</a>
            </td>
        </thead>
        <tr>
            <td>类型</td>
            <td>
                <select bind-value="{{type}}" bind-input="{{'type'}}">
                    <option>---- 无 ----</option>
                    <option selected="{{(type=='media_id')}}" value="media_id">图片</option>
                    <option selected="{{(type=='view_limited')}}" value="view_limited">图文消息</option>
                    <option selected="{{(type=='view')}}" value="view">链接</option>
                </select>
            </td>
            <td>名称</td>
            <td>
            	<input type="text" bind-input="{{'name'}}" bind-value="{{name}}" placeholder="按钮名称" maxlength="8" />
            </td>
        </tr>

        <tr>
	        {{#if type=='view'}}
			<td>链接</td>
			<td colspan="3">
				<input class="wide" type="text" bind-input="{{'url'}}" bind-value="{{url}}" maxlength="256" />
			</td>
	        {{/if}}
	        {{#if type=='media_id'}}
			<td>资源id</td>
			<td colspan="3">
				<input class="wide" type="text" bind-input="{{'media_id'}}" bind-value="{{media_id}}" />
			</td>
	        {{/if}}
	        {{#if type=='view_limited'}}
			<td>资源id</td>
			<td colspan="3">
				<input class="wide" type="text" bind-input="{{'media_id'}}" bind-value="{{media_id}}" />
			</td>
	        </tr>
	        {{/if}}
		<tr>
			<td colspan="4" class="title">二级菜单</td>
		</tr>
        {{#each sub_button}}
		<tr>
			<td>类型</td>
			<td>
                <select bind-value="{{type}}" bind-input="{{'type'}}">
                    <option selected="{{(type=='media_id')||!type}}" value="media_id">图片</option>
                    <option selected="{{(type=='view_limited')}}" value="view_limited">图文消息</option>
                    <option selected="{{(type=='view')}}" value="view">链接</option>
                </select>
                <a class="method" event-click="{{'$Top.$Event.admin.createbutton.removeSub'}}">删除此菜单</a>
            </td>
            <td>名称</td>
            <td>
            	<input type="text" bind-input="{{'name'}}" bind-value="{{name}}" placeholder="按钮名称" maxlength="8" />
            </td>
		</tr>
		<tr>
			{{#if type=='view'}}
			<td>链接</td>
			<td colspan="3">
				<input class="wide" type="text" bind-input="{{'url'}}" bind-value="{{url}}" maxlength="256" />
			</td>
	        {{/if}}
	        {{#if type=='media_id'}}
			<td>资源id</td>
			<td colspan="3">
				<input class="wide" type="text" bind-input="{{'media_id'}}" bind-value="{{media_id}}" />
			</td>
	        {{/if}}
	        {{#if type=='view_limited'}}
			<td>资源id</td>
			<td colspan="3">
				<input class="wide" type="text" bind-input="{{'media_id'}}" bind-value="{{media_id}}" />
			</td>
	        </tr>
	        {{/if}}
		</tr>
		<tr>
			<td colspan="4" class="cutline"></td>
		</tr>
        {{/each}}
        {{#if 5>sub_button.length}}
		<tr>
			<td colspan="4">
				<button event-click="{{'$Top.$Event.admin.createbutton.addSub'}}">添加二级菜单</button>
			</td>
		</tr>
        {{/if}}
    </table>
    {{/each}}
    <div class="method">
    	{{#if 3>$Cache.admin.createbutton.list.button.length}}
		<button event-click="{{'$Event.admin.createbutton.addButton'}}">添加一级菜单</button>
    	{{/if}}
    	<button event-click="{{'$Event.admin.createbutton.submit'}}">提交</button>
    </div>
</div>
